@echo off

if "%1" == "" goto syntax_error
if "%2" == "" goto syntax_error
if "%3" == "" goto syntax_error
if "%4" == "" goto syntax_error

set TOOL_DBSERVER=%1
set TOOL_DBNAME=%2
set TOOL_DBACCOUNT=%3
set TOOL_DBPASSWORD=%4
set TOOL_DBVIEWSDIR=Views

@echo Create views....

@echo BookingView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.BookingView.View.sql
if errorlevel 1 goto sql_error

@echo CouplesWithIndividualBookingView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.CouplesWithIndividualBookingView.View.sql
if errorlevel 1 goto sql_error

@echo CouplesWithOrdinaryBookingView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.CouplesWithOrdinaryBookingView.View.sql
if errorlevel 1 goto sql_error

@echo CouplesWithPreferredDateView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.CouplesWithPreferredDateView.View.sql
if errorlevel 1 goto sql_error

@echo CoupleView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.CoupleView.View.sql
if errorlevel 1 goto sql_error

@echo IndividualBookingRegisterView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.IndividualBookingRegisterView.View.sql
if errorlevel 1 goto sql_error

@echo MinisterTimeBlock
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.MinisterTimeBlock.View.sql
if errorlevel 1 goto sql_error

@echo OrdinaryBookingCeremonyView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.OrdinaryBookingCeremonyView.View.sql
if errorlevel 1 goto sql_error

@echo OrdinaryBookingRegisterView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.OrdinaryBookingRegisterView.View.sql
if errorlevel 1 goto sql_error

@echo ReportMarriageCertificateTextView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportMarriageCertificateTextView.View.sql
if errorlevel 1 goto sql_error

@echo ReportMarriageCertificateView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportMarriageCertificateView.View.sql
if errorlevel 1 goto sql_error

@echo ReportMarriageMinutesView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportMarriageMinutesView.View.sql
if errorlevel 1 goto sql_error

@echo ReportMarriageRegisterView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportMarriageRegisterView.View.sql
if errorlevel 1 goto sql_error

@echo ReportMinisterServiceView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportMinisterServiceView.View.sql
if errorlevel 1 goto sql_error

@echo ReportReimbursmentView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.ReportReimbursmentView.View.sql
if errorlevel 1 goto sql_error

@echo TicketView
call SqlCommand %TOOL_DBSERVER% %TOOL_DBNAME% %TOOL_DBACCOUNT% %TOOL_DBPASSWORD% %TOOL_DBVIEWSDIR%\dbo.TicketView.View.sql
if errorlevel 1 goto sql_error


@echo *************************************************************
@echo *
@echo * All views created successfully.
@echo *
@echo *************************************************************
goto end


:syntax_error
@echo *************************************************************
@echo *
@echo * Syntax error!
@echo * Required parameter is missing.
@echo *
@echo * Usage: CreateViews 'DatabaseServerName' DatabaseName' 'Account' 'Password'
@echo *
@echo *************************************************************
goto end


:sql_error
:end
